package gemini.pollux.ui.client.mvp.event;

import gemini.pollux.ui.client.utils.UIConstants.LayoutPosition;
import ch.elca.gwt.mvp.client.widget.WidgetPresenter;

import com.google.gwt.event.shared.GwtEvent;

public class WidgetChangeEvent extends GwtEvent<WidgetChangeHandler> {

    private static Type<WidgetChangeHandler> TYPE;
    
    private WidgetPresenter<?> widgetPresenter;
    private LayoutPosition position;

    public static Type<WidgetChangeHandler> getType() {
        if (TYPE == null) {
            TYPE = new Type<WidgetChangeHandler>();
        }
        return TYPE;
    }

    public WidgetChangeEvent(final WidgetPresenter<?> p, LayoutPosition position) {
        this.widgetPresenter = p;
        this.position = position;
    }

    public WidgetPresenter<?> getWidgetPresenter() {
        return widgetPresenter;
    }
    
    public LayoutPosition getPosition() {
		return position;
	}

	@Override
    public final Type<WidgetChangeHandler> getAssociatedType() {
        return getType();
    }

    @Override
    protected void dispatch(final WidgetChangeHandler handler) {
        handler.onChange(this);
    }
}
